require 'jerbil'

SCALA_HOME          = ENV["SCALA_HOME"].gsub(/\\/, "/");
SCALA_LIBS          = FileList["#{SCALA_HOME}/lib/**/*.jar"]

LIB_DIR             = File.join(Rake.original_dir, "lib")

CLASSPATH           = FileList["build", "#{LIB_DIR}/**/*.jar"]; 

load_jvm(CLASSPATH , [])

task :default => :compile

task :compile do
#  sh "cp -R resources build" unless File.exists?("build")
  Dir.mkdir("build") unless File.exists? "build"
  sh "fsc -cp \"#{CLASSPATH.to_cp}\" -d build #{FileList["src/**/*.scala"]}"
end

task :clean  do |t|
  rm_rf "build"
  sh "fsc -shutdown"
end

task :jar => [:clean, :compile] do 
  sh "jar -cf preferscala.jar -C build ."
end
